package Eyjafjalla.power;

import Eyjafjalla.action.GainCloudEnergyAction;
import Eyjafjalla.patch.MelodyPatch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.megacrit.cardcrawl.actions.unique.LoseEnergyAction;
import com.megacrit.cardcrawl.core.AbstractCreature;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.helpers.ImageMaster;
import com.megacrit.cardcrawl.localization.PowerStrings;

public class AnswerInWindPower extends AbstractEyjafjallaPower {
    public static final String POWER_ID = "eyjafjalla:AnswerInWindPower";
    private static final PowerStrings powerStrings;

    public AnswerInWindPower(AbstractCreature owner, int amount){
        this.name = powerStrings.NAME;
        this.ID = POWER_ID;
        this.owner = owner;
        this.amount = amount;
        this.updateDescription();
        String path128 = "EyjafjallaResources/img/power/AnswerInCloudPower_84.png";
        String path48 = "EyjafjallaResources/img/power/AnswerInCloudPower_32.png";
        this.region128 = new TextureAtlas.AtlasRegion(ImageMaster.loadImage(path128),0,0,84,84);
        this.region48 = new TextureAtlas.AtlasRegion(ImageMaster.loadImage(path48),0,0,32,32);
        this.isTurnBased = true;
        this.type = PowerType.BUFF;
    }

    public void triggerWhenMelodyStart(MelodyPatch.MelodySingle single){
        if(single.notes==null)
            return;
        this.flash();
        int remain = this.amount;
        for(int i = single.notes.size()-1;i>=0&&remain>0;i--){
            remain--;
            single.notes.get(i).setNote(0);
        }
    }

    @Override
    public void updateDescription() {
        this.description = powerStrings.DESCRIPTIONS[0] + this.amount + powerStrings.DESCRIPTIONS[1];
    }

    static {
        powerStrings = CardCrawlGame.languagePack.getPowerStrings(POWER_ID);
    }
}


